﻿Public Class Product

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Application.Exit()
    End Sub

    Private Sub Product_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'ProductsDataSet.Products' table. You can move, or remove it, as needed.
        Dim databaseProvider As DatabaseProvider = databaseProvider.Instance()
        ProductDataGrid.DataSource = databaseProvider.GetAllProducts()
        ProductsToolStripMenuItem.Enabled = False

    End Sub

    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    End Sub

    Private Sub BtnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDel.Click
        If MsgBox("Are You Sure?", MsgBoxStyle.YesNo, Title:="Confirm") = vbYes Then
            Me.ProductsBindingSource.RemoveCurrent()
            Me.Validate()
            Me.ProductsBindingSource.EndEdit()
        End If
    End Sub

    Private Sub ChooseLanguageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChooseLanguageToolStripMenuItem.Click
        Language.Show()
        Me.Close()
    End Sub

    Private Sub AdminToolsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AdminToolsToolStripMenuItem.Click
        Start.Show()
        Me.Close()
    End Sub

    Private Sub StaffMembersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StaffMembersToolStripMenuItem.Click
        Employee.Show()
        Me.Close()
    End Sub

    Private Sub CustomersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomersToolStripMenuItem.Click
        Customer.Show()
        Me.Close()
    End Sub

    Private Sub SalesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalesToolStripMenuItem.Click
        Sales.Show()
        Me.Close()
    End Sub

    Private Sub OrdersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrdersToolStripMenuItem.Click
        Orders.Show()
        Me.Close()
    End Sub

    Private Sub HelpToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripMenuItem1.Click
        Help.Show()
    End Sub

    Private Sub TxtProduct_TextChanged(sender As System.Object, e As System.EventArgs) Handles TxtProduct.TextChanged
        ProductDataGrid.DataSource = productSearch()
    End Sub

    Private Sub TxtPName_TextChanged(sender As System.Object, e As System.EventArgs) Handles TxtPName.TextChanged
        ProductDataGrid.DataSource = productSearch()
    End Sub

    Private Sub TxtMaterial_TextChanged(sender As System.Object, e As System.EventArgs) Handles TxtMaterial.TextChanged
        ProductDataGrid.DataSource = productSearch()
    End Sub

    Private Sub TxtColour_TextChanged(sender As System.Object, e As System.EventArgs) Handles TxtColour.TextChanged
        ProductDataGrid.DataSource = productSearch()
    End Sub

    Private Function productSearch() As BindingSource
        Dim databaseProvider As DatabaseProvider = databaseProvider.Instance()
        Return databaseProvider.FindProduct(TxtPName.Text, TxtMaterial.Text, TxtColour.Text, TxtProduct.Text)
    End Function

    Private Sub BtnAdd_Click(sender As System.Object, e As System.EventArgs) Handles BtnAdd.Click
        NewProduct.Show()
    End Sub

    Private Sub ProductDataGrid_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ProductDataGrid.CellContentClick

    End Sub
End Class